package ms;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Test1 {
	public static void main(String[] argsStrings) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			
			List<Integer> pList = new ArrayList<Integer>();
			List<Integer> qList = new ArrayList<Integer>();

			int p = in.nextInt();
			int q = in.nextInt();
			for (int i = 1; i * i <= p; i++) {
				if (p % i == 0) {
					pList.add(i);
					int k = p / i;
					if (i != k)
						pList.add(k);
				}
			}
			for(int i=1;i* i<=q;i++){
				if(q%i == 0){
					qList.add(i);
					int k = q/i;
					if(i!=k)
						qList.add(k);
				}
			}
			Collections.sort(pList);
			Collections.sort(qList);
			for(Integer i:pList){
				for(Integer j:qList){
					System.out.println(i+" "+j);
				}
			}
		}
	}
}
